package com.tanhua.admin.controller;

import com.tanhua.admin.service.AnalysisService;
import com.tanhua.model.vo.AnalysisSummaryVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.ws.rs.GET;
import java.util.List;
import java.util.Map;
@Slf4j
@RestController
@RequestMapping("/dashboard")
public class DashboardController {
    @Autowired
    private AnalysisService analysisService;


//    新增/活跃用户、次日留存率
//    GET   /dashboard/users

//    概要统计信息
//    GET   /dashboard/summary
    @GetMapping("/summary")
    public AnalysisSummaryVo getSummaryVo(){
        AnalysisSummaryVo analysisSummaryVo = analysisService.getSummary();
        return analysisSummaryVo;
    }

    //后台-次日留存统计
    @GetMapping("/users")
    public Map<String, List<Map<String,Object>>> getUsers(@RequestParam Long sd ,@RequestParam Long ed,@RequestParam Long type) {
        log.info("请求参数为:"+sd);
        log.info("请求参数为:"+ed);
        log.info("请求参数为:"+type);

        Map<String, List<Map<String,Object>>> result = analysisService.getUsers(sd,ed,type);
        log.info("result: {}",result);
        return result;
    }
}
